<?php echo $this->Html->css('search'); ?>
<?php echo $this->Html->script('facebook_functions'); ?>
<div id="main">
	<div class="post-content">
		<div class="content_inner">
			<div class="first-row">
				<span class="title">PRODUCTS WE ARE SELLING</span>
			</div>

			<div class="products">
				<? foreach($products as $post) { ?>
					<div class="product first ptile">
						<a href="<?=$this->webroot.'products/view/'.$post['Product']['id']?>" class="product-wrapper">
							<?=$html->image($thumb->image('posts/'.$post['Product']['image']),
								array('width' => 180,'height' => 180, 'class' => 'attachment-shop_catalog wp-post-image'));?>
							<h3 class="product-title" style="height:40px"><?=$post['Product']['name']?></h3>
							<div class="excerpt"><p><?echo Sanitize::stripTags($post['Product']['short_description'])?></p></div>
						</a>
						<a href="<?=$this->webroot.'deals/product_deals/'.$post['Product']['id']?>" rel="nofollow" data-product_id="126" class="btn btn-reset">View Deals</a>
						<a href="#" onclick="share_product(
                                '<?=$post["Product"]["name"]?>',
                                'Dealcruncher is selling <?=$post["Product"]["name"]?>. Visit our website to view the deals!',
                                'products/view/<?=$post["Product"]["id"]?>'); return false;" class="btn btn-reset" style="margin-right:5px">Share</a>
					</div>
				<? } ?>
			</div>
			<div class="pagination search-filter" style="width:50%">
		        <?php
		        if($this->Paginator->hasPrev()){
		            echo $this->Paginator->prev('<span>&lt;</span>', array('escape'=>false));
		        }
		        ?>
		        <?php echo $this->Paginator->numbers(array('first'=>1,'modulus'=>4, 'last'=>1, 'separator' => '&nbsp;'));?>
		        <?php
	            if($this->Paginator->hasNext()){
	                echo $this->Paginator->next('<span>&gt;</span>', array('escape'=>false));
	            }
		        ?>
			</div>
		</div>
	</div>
</div>
<script>
window.fbAsyncInit = function() {
    FB.init({
      appId      : '<?=FB_API_KEY?>', // App ID
      channelUrl : 'http://dealcrunch.com/dealcruncher', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

    // Additional initialization code here
  };

  // Load the SDK Asynchronously
  (function(d){
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));
</script>
